package com.dao.impl;
import com.beans.UserInfo;
import com.dao.UserDao;
import com.jdbc.DBUtil;

public class UserDaoImpl implements UserDao {
	//添加用户
	public void addUser(UserInfo user) {
		String sql="insert into  userinfo (userName,password,phone) values (?,?,?)";
		DBUtil.update(sql, user.getUserName(),user.getPassword(),user.getPhone());
	}

	//根据账号查询用户
	public UserInfo getUserByName(String userName) {

		return DBUtil.getSingleObj("select * from userinfo where userName=?limit 1",UserInfo.class, userName);
	}

	//登录
	public UserInfo login(String userName, String password) {
		String sql="select * from userinfo where userName=? and password=?" ; 
		return DBUtil.getSingleObj(sql, UserInfo.class, userName,password);
	}
}